﻿@using PagedList.Mvc;
@model BBICMS.Model.ViewModel.Back.TeamListVM


@{
    ViewBag.Title = "团队成员";
    ViewBag.PageTitle = ViewBag.Title + "_内容";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}





    <div class="panel panel-default">
        <header class="panel-heading">
            <span class="glyphicon glyphicon-file"></span> @ViewBag.Title
        </header>

        <section class="panel-body text-right">
            
                <a class="btn btn-primary" href="@Url.Action("Add")"><i class="glyphicon glyphicon-plus"></i> 添加成员</a>
          
        </section>

        <div class="table-responsive">
            <table class="table table-hover table-vmiddle">
                <thead>
                    <tr>
                        <th></th>
                        <th>
                            昵称
                        </th>
                        <th>
                            姓名
                        </th>
                        <th>
                            职业
                        </th>
                        <th>
                            <span class="glyphicon glyphicon-user"></span> 发布者
                        </th>
                        <th>
                            <span class="glyphicon glyphicon-time"></span> 创建日期
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var Member in Model.OnePageOfTeams)
                    {
                        <tr class="first">
                            <td>
                                @if (!string.IsNullOrEmpty(Member.PhotoUrl))
                                {
                                    <img src="@string.Format("{0}?w=30&h=30&mode=crop", Member.PhotoUrl)" class="img-thumbnail" />
                                }
                            </td>

                            <td>
                                @Member.Nickname
                            </td>
                            <td>
                                @Member.RealName
                            </td>
                            <td>
                                @Member.Post
                            </td>
                            <td>
                                @Member.AddedBy
                            </td>


                            <td>@Member.AddedDate.ToShortDateString()</td>
                            <td>
                                <a href="@Url.Action("Edit", new { Id = Member.Id })" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
                                <a href="@Url.Action("Delete", new { Id = Member.Id })" class="btn btn-xs btn-danger delete-team"><i class="glyphicon glyphicon-trash"></i></a>
                            </td>
                        </tr>
                    }

                </tbody>

            </table>



        </div>


        <footer class="panel-footer">
            <ul class="pagination">
                @Html.PagedListPager(Model.OnePageOfTeams, page => Url.Action("Index", new { page }))
            </ul>
        </footer>


    </div>

<!-- end main container -->
@section footer {

    <script>

        $(function () {
            //当前菜单;
            //$('.mainmenu>li:nth-of-type(3)').addClass('nav-open').find('.submenu li:nth-of-type(2) a').addClass('active');


            //删除数据
            $('.delete-team').click(function (e) {
                var url = $(this).attr('href');
                var that = $(this);
               // console.log(url);
                /*DELETE*/
                $.ajax({
                    url: url,
                    dataType: "json",
                    type: "DELETE",
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify({}),
                    async: true,
                    processData: false,
                    cache: false,
                    success: function (data) {
                        if (data) {
                            toastr.success('成员已删除成功！', '删除成员');
                            that.closest('tr').remove();
                        } else {
                            toastr.error('成员删除失败！', '删除成员');
                        }
                    },
                    error: function (xhr) {
                        toastr.error('成员删除失败！', '删除成员');
                    }
                });

                e.preventDefault();
            })

        });
    </script>

}